package com.ry;
import com.ry.util.timepick.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ry.util.CommonConstants;

public class FlightOrTrainInformationActivity extends Activity {
	private Button btnBack;
	private TextView txtTittle;
	private Button btnNext;
	private Button btnLeft;
	private Button btnRight;
	private RelativeLayout rlytLeft0;
	private RelativeLayout rlytLeft1;
	private RelativeLayout rlytRight0;
	private RelativeLayout rlytRight1;
	private TextView txtLeft00;
	private TextView txtLeft01;
	private TextView txtLeft10;
	private TextView txtLeft11;
	private TextView txtRight00;
	private TextView txtRight01;
	private TextView txtRight10;
	private TextView txtRight11;

	private String type;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.flght_or_train_information);
		init();
	}

	private void init() {
		type = getIntent().getStringExtra("type");
		if (type == null) {
			return;
		}

		btnBack = (Button) findViewById(R.flght_or_train_information.btn_back);
		txtTittle = (TextView) findViewById(R.flght_or_train_information.txt_tittle);
		btnNext = (Button) findViewById(R.flght_or_train_information.btn_next);
		btnLeft = (Button) findViewById(R.flght_or_train_information.btn_left);
		btnRight = (Button) findViewById(R.flght_or_train_information.btn_right);
		rlytLeft0 = (RelativeLayout) findViewById(R.flght_or_train_information.rlyt_left_0);
		rlytLeft1 = (RelativeLayout) findViewById(R.flght_or_train_information.rlyt_left_1);
		rlytRight0 = (RelativeLayout) findViewById(R.flght_or_train_information.rlyt_right_0);
		rlytRight1 = (RelativeLayout) findViewById(R.flght_or_train_information.rlyt_right_1);
		txtLeft00 = (TextView) findViewById(R.flght_or_train_information.txt_left_00);
		txtLeft01 = (TextView) findViewById(R.flght_or_train_information.txt_left_01);
		txtLeft10 = (TextView) findViewById(R.flght_or_train_information.txt_left_10);
		txtLeft11 = (TextView) findViewById(R.flght_or_train_information.txt_left_11);
		txtRight00 = (TextView) findViewById(R.flght_or_train_information.txt_right_00);
		txtRight01 = (TextView) findViewById(R.flght_or_train_information.txt_right_01);
		txtRight10 = (TextView) findViewById(R.flght_or_train_information.txt_right_10);
		txtRight11 = (TextView) findViewById(R.flght_or_train_information.txt_right_11);

		if (type.equals(CommonConstants.AIRPORT_PICK_UP) || type.equals(CommonConstants.AIRPORT_DROP_OFF)) {
			txtTittle.setText("航班信息");
			btnLeft.setBackgroundResource(R.drawable.plane_number_hover);
			btnRight.setBackgroundResource(R.drawable.plane_area);
			txtLeft00.setText("航班号");
			txtLeft01.setText("请选择航班号");
			txtLeft10.setText("航班起飞日期");
			txtLeft11.setText("请选择航班起飞日期");
			txtRight00.setText("到达机场");
			txtRight01.setText("选择机场");
			txtRight10.setText("到达时间");
			txtRight11.setText("选择时间");
		} else if (type.equals(CommonConstants.TRAIN_PICK_UP) || type.equals(CommonConstants.TRAIN_DROP_OFF)) {
			txtTittle.setText("列车信息");
			btnLeft.setBackgroundResource(R.drawable.train_number_active);
			btnRight.setBackgroundResource(R.drawable.train_area);
			txtLeft00.setText("列车车次");
			txtLeft01.setText("请选择列车车次");
			txtLeft10.setText("到达日期");
			txtLeft11.setText("请选择到达日期");
			txtRight00.setText("到达车站");
			txtRight01.setText("选择车站");
			txtRight10.setText("到达时间");
			txtRight11.setText("选择时间");
		}

		btnLeft.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (type.equals(CommonConstants.AIRPORT_PICK_UP) || type.equals(CommonConstants.AIRPORT_DROP_OFF)) {
					btnLeft.setBackgroundResource(R.drawable.plane_number_hover);
					btnRight.setBackgroundResource(R.drawable.plane_area);
				} else if (type.equals(CommonConstants.TRAIN_PICK_UP) || type.equals(CommonConstants.TRAIN_DROP_OFF)) {
					btnLeft.setBackgroundResource(R.drawable.train_number_active);
					btnRight.setBackgroundResource(R.drawable.train_area);
				}
				rlytLeft0.setVisibility(View.VISIBLE);
				rlytLeft1.setVisibility(View.VISIBLE);
				rlytRight0.setVisibility(View.GONE);
				rlytRight1.setVisibility(View.GONE);
			}
		});

		btnRight.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (type.equals(CommonConstants.AIRPORT_PICK_UP) || type.equals(CommonConstants.AIRPORT_DROP_OFF)) {
					btnLeft.setBackgroundResource(R.drawable.plane_number);
					btnRight.setBackgroundResource(R.drawable.plane_area_hover);
				} else if (type.equals(CommonConstants.TRAIN_PICK_UP) || type.equals(CommonConstants.TRAIN_DROP_OFF)) {
					btnLeft.setBackgroundResource(R.drawable.train_number);
					btnRight.setBackgroundResource(R.drawable.train_area_active);
				}
				rlytLeft0.setVisibility(View.GONE);
				rlytLeft1.setVisibility(View.GONE);
				rlytRight0.setVisibility(View.VISIBLE);
				rlytRight1.setVisibility(View.VISIBLE);
			}
		});

		btnBack.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				FlightOrTrainInformationActivity.this.finish();
			}
		});

		btnNext.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(FlightOrTrainInformationActivity.this, OrderInformaionActivity.class);
				startActivity(intent);
			}
		});
	}

}
